package com.itheima.io;

import java.io.*;

/**
 * @author Anomaly
 * @date 2023/2/9 17:19
 */

/**
 * 文件拷贝
 */
public class OutputStreamDemo2 {
    public static void main(String[] args) {
        try {
            InputStream is = new FileInputStream("file-io/src/test.txt");
            OutputStream os = new FileOutputStream("file-io/src/test_2.txt");
            byte[] bytes = new byte[1024];
            int len;
            while ((len = is.read(bytes)) != -1) {
                os.write(bytes, 0, len);
            }
            System.out.println("拷贝完成。");
            os.close();
            is.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
